﻿using System;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.Exceptions;
using Autodesk.Revit.UI;

namespace YJKRevitInnerCmd
{
	[Transaction(TransactionMode.Manual)]
	[Regeneration(RegenerationOption.Manual)]
	public class CmdArchitecturalWall : IExternalCommand
	{
		public Result Execute(ExternalCommandData cmdData, ref string msg, ElementSet elems)
		{
			RevitCommandId revitCommandId = RevitCommandId.LookupPostableCommandId(Autodesk.Revit.UI.PostableCommand.ArchitecturalWall);
			try
			{
				if (cmdData.Application.CanPostCommand(revitCommandId))
				{
					cmdData.Application.PostCommand(revitCommandId);
				}
			}
			catch (Autodesk.Revit.Exceptions.InvalidOperationException)
			{
				return Autodesk.Revit.UI.Result.Succeeded;
			}
			return Autodesk.Revit.UI.Result.Succeeded;
		}
	}
}
